﻿
Imports CoreCode
Imports CoreCode.Connection
Imports System.Windows.Forms
Imports System.Reflection

Public Class ExpansionModule
    Dim clsCon_ As Connection
    Dim DSet As DataSet

    Public Property clsCon() As Connection
        Get
            clsCon = clsCon_
        End Get
        Set(ByVal value As Connection)
            clsCon_ = value
        End Set
    End Property

    Public Sub CallComponent(ByVal oBar As Object, ByVal sComponent As String, ByVal sCaption As String)
        Try
            Dim sAssemblyType()
            sAssemblyType = Split(sComponent, ".")

            Dim asm As System.Reflection.Assembly = Assembly.Load(Trim(sAssemblyType(0)))
            Dim obj As Object = Activator.CreateInstance(asm.GetType(Trim(sAssemblyType(0)) & "." & Trim(sAssemblyType(1))))

            obj.Name = sAssemblyType(1)
            LoadComponent(oBar, obj, sCaption)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    ''' <summary>
    ''' Procedure to call a component
    ''' </summary>
    ''' <param name="oBar">Bar Control</param>
    ''' <param name="oComponent">Name of the component</param>
    ''' <param name="sCaption">Caption of the component</param>
    ''' <remarks></remarks>
    Public Sub LoadComponent(ByVal oBar As Object, ByVal oComponent As Object, ByVal sCaption As String)
        Dim pdContainer As New DevComponents.DotNetBar.PanelDockContainer
        Dim dcItem As New DevComponents.DotNetBar.DockContainerItem

        oBar.Items.Add(dcItem)

        With dcItem
            .Control = pdContainer
            .Text = sCaption
        End With

        With pdContainer
            .Controls.Add(oComponent)
            .Location = New System.Drawing.Point(3, 28)
            .Size = New System.Drawing.Size(725, 393)
            .Style.Alignment = System.Drawing.StringAlignment.Center
            .Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground
            .Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder
            .Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText
            .Style.GradientAngle = 90
            .TabIndex = 0
        End With

        With oComponent
            .Dock = System.Windows.Forms.DockStyle.Fill
            .Location = New System.Drawing.Point(0, 0)
            .Size = New System.Drawing.Size(725, 393)
            .TabIndex = 0
        End With

        dcItem.Focus()

     End Sub

End Class
